package com.example.seed.web;

import com.example.seed.dto.SysUserSpecification;
import com.example.seed.entity.SysUser;
import com.example.seed.service.SysUserRepository;
import jakarta.annotation.Resource;
import org.babyfish.jimmer.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sys/user")
public class SysUserController {

    @Resource
    private SysUserRepository sysUserRepository;

    /**
     * 测试qbe
     *
     * @param pageIndex     页面索引
     * @param pageSize      页面大小
     * @param specification 规范
     * @return {@link Page}<{@link @FetchBy("FULL_ELEMENT")} {@link SysUser}>
     */
    @GetMapping("/list")
    public Page<SysUser> list(@RequestParam(defaultValue = "0") int pageIndex,
                              @RequestParam(defaultValue = "10") int pageSize,
                              @RequestParam(required = false) SysUserSpecification specification) {

        //Page<SysUser> all = sysUserRepository.page(pageIndex, pageSize, specification, Fetchers
        //                .SYS_USER_FETCHER
        //                .allTableFields()
        //                .password(false)
        //                .createdUsers(Fetchers.SYS_USER_FETCHER.account())
        //                .sysRoles(Fetchers.SYS_ROLE_FETCHER.name()
        //                        .createdBy(Fetchers.SYS_USER_FETCHER.account())
        //                        .sysPermissions(Fetchers.SYS_PERMISSION_FETCHER.name())),
        //        Sort.by(Order.orderedPropChain("createdTime"))
        //);
        //return all;
        return null;
    }
}
